package com.lanou.service.T8TService.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lanou.bean.T8Tcommodity.Brand;
import com.lanou.bean.T8Tcommodity.Commodity;
import com.lanou.mapper.T8TCommodityMapper;
import com.lanou.service.T8TService.T8TService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by dllo on 18/3/17.
 */
@Service
public class T8TServiceImpl implements T8TService {
    @Resource
    private T8TCommodityMapper commodityMapper;

    @Override
    public List<Commodity> findCommodity(
            Integer SD,
            Integer PA,
            Integer C1ID,
            Integer C2ID,
            Integer C3ID,
            Integer C4ID,
            Double priceMax,
            Double priceMin) {
        return commodityMapper.findCommodity(SD,PA,C1ID,C2ID,C3ID,C4ID,priceMax,priceMin);
    }
    @Override
    public PageInfo<Commodity> findCommodityPage(Integer pageNo,
                                                 Integer pageSize,
                                                 Integer SD,
                                                 Integer PA,
                                                 Integer C1ID,
                                                 Integer C2ID,
                                                 Integer C3ID,
                                                 Integer C4ID,
                                                 Double priceMax,
                                                 Double priceMin){

        pageNo = pageNo == null ? 1 : pageNo;
        pageSize = pageSize == null ? 10 : pageSize;
        PageHelper.startPage(pageNo, pageSize);
        List<Commodity> commodityList = commodityMapper.findCommodity(SD,PA,C1ID,C2ID,C3ID,C4ID,priceMax,priceMin);
        PageInfo<Commodity> commodityPageInfo = new PageInfo<Commodity>(commodityList);
        return commodityPageInfo;

    }

    @Override
    public Commodity findCommodityBycommodityID(Integer commodityID) {
        return commodityMapper.findCommodityBycommodityID(commodityID);
    }

    @Override
    public List<Brand> findBrand(Integer C2ID, Integer C3ID) {
        return commodityMapper.findBrandByclassId(C2ID,C3ID);
    }
}
